﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Sharemp3DataContext db = new Sharemp3DataContext();

            var albumtophot = (from i in db.Albums
                               select new
                               {
                                   AlbumID = i.AlbumID,
                                   AlbumName = i.AlbumName,
                                   ArtistName = i.Artist.ArtistName,
                                   Date = i.Date,
                                   Rating = i.Rating,
                                   AlbumCover = i.AlbumCover
                               }).OrderByDescending(i => i.Rating).Take(10);

            Rpt_AlbumTopHot.DataSource = albumtophot;
            Rpt_AlbumTopHot.DataBind();

            var musiclst = (from i in db.Musics
                            select new
                            {
                                MusicID = i.MusicID,
                                Title = i.Title,
                                AlbumID = i.AlbumID,
                                AlbumName = i.Album.AlbumName,
                                ArtistID = i.Album.ArtistID,
                                ArtistName = i.Album.Artist.ArtistName,
                                Rating = i.Rating,
                                Date = i.Album.Date
                            }).OrderByDescending(i => i.Rating).Take(10);

            Rpt_MusicList.DataSource = musiclst;
            Rpt_MusicList.DataBind();

            var videolst = (from i in db.VideoClips
                            select new
                            {
                                VideoID = i.VideoID,
                                Title = i.Title,
                                AlbumID = i.AlbumID,
                                AlbumName = i.Album.AlbumName,
                                ArtistID = i.Album.ArtistID,
                                ArtistName = i.Album.Artist.ArtistName,
                                Rating = i.Rating,
                                Poster = i.Poster,
                                Date = i.Album.Date
                            }).OrderByDescending(i => i.Date).Take(10);

            Rpt_VideoList.DataSource = videolst;
            Rpt_VideoList.DataBind();
        }
    }
}